﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Threading;

namespace IPSwitcher
{
    class Program
    {
        static void Main(string[] args)
        {
            string switcherName = ConfigurationManager.AppSettings["IPSwitcher"];
            int switchPeriod = int.Parse(ConfigurationManager.AppSettings["SwitchIPPeriod"]);
            if (switchPeriod <= 0)
            {
                return;
            }

            IIPSwitcher switcher = Activator.CreateInstance(Type.GetType(switcherName)) as IIPSwitcher;
            while (true)
            {
                Thread.Sleep(switchPeriod);
                Console.WriteLine("Switch IP at: " + DateTimeOffset.Now.ToString());
                switcher.SwitchIP();
            }
        }
    }
}
